home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Apple Game Sprockets / DrawSprocket / GoggleSprocket / GoggleSprocketTest Sources / GSpTest_Init.cp < prev    next >
Encoding:
Text File  |  1998-03-12  |  2.0 KB  |  105 lines  |  [TEXT/CWIE]

  1. /*
  2. ********************************************************************************
  3. **
  4. ** File: GSpTest_Init.cp
  5. **
  6. ** Description:
  7. **
  8. **    Initialization and termination routines.
  9. **
  10. ********************************************************************************
  11. */
  12. #include "DrawSprocket.h"
  13.  
  14. #include "GSpTest_Main.h"
  15. #include "GSpTest_Init.h"
  16. #include "GSpTest_AEvt.h"
  17. #include "GSpTest_EventLoop.h"
  18. #include "GSpTest_DSpSupport.h"
  19.  
  20. #include "GoggleSprocket.h"
  21.  
  22. /*
  23. ********************************************************************************
  24. **
  25. ** Name: Initialize
  26. **
  27. ** Description:
  28. **
  29. **    Toolbox initialization.
  30. **
  31. ********************************************************************************
  32. */
  33. OSErr                // result code
  34. Initialize( void )
  35. {
  36.     OSErr theError;
  37.     Handle theMenuBar;
  38.     
  39.     // init Mac toolbox
  40.     InitGraf( &qd.thePort );
  41.     InitFonts();
  42.     InitWindows();
  43.     InitMenus();
  44.     TEInit();
  45.     InitDialogs(nil);
  46.     InitCursor();
  47.     FlushEvents( everyEvent, 0 );
  48.     theError = AEStartup();
  49.     if( theError )
  50.         return kError_AppleEvents;
  51.  
  52.     // setup menus
  53.     theMenuBar = GetNewMBar( kMBAR_ID );
  54.     if( NULL == theMenuBar )
  55.         return kError_ResNotFound;
  56.     SetMenuBar( theMenuBar );
  57.     DisposeHandle( theMenuBar );
  58.     AppendResMenu( GetMenuHandle( kMenu_Apple ), 'DRVR');
  59.     DrawMenuBar();
  60.         
  61.     // init and put the display into paused mode
  62.     theError = DisplayInit();
  63.     if( theError )
  64.         return theError;
  65.     DisplayFadeOut();
  66.     theError = DisplayPause();
  67.     DisplayFadeIn();
  68.     if( theError )
  69.         return theError;
  70.  
  71.     // startup goggle sprocket
  72.     theError = GSpStartup( NULL );
  73.     if( theError )
  74.         return theError;
  75.  
  76.     // set the arrow cursor
  77.     SetCursor( &qd.arrow );
  78.  
  79.     // done
  80.     return theError;
  81. }
  82.  
  83. /*
  84. ********************************************************************************
  85. **
  86. ** Name: Terminate()
  87. **
  88. ** Description:
  89. **
  90. **    Cleanup and terminate.
  91. **
  92. ********************************************************************************
  93. */
  94. void Terminate( void )
  95. {
  96.     GSpShutdown( NULL );
  97.  
  98.     // DisplayRelease() will fade out/in
  99.     DisplayRelease();
  100.  
  101.     AEShutdown();
  102.     
  103.     ExitToShell();
  104. }
  105.